package app.rci.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import app.rci.dao.UserModelDAO;
import app.rci.domain.LoginData;
import app.rci.model.UserModel;
import app.rci.model.UserModelExample;
import app.rci.model.UserModelExample.Criteria;
import app.rci.service.LoginService;

@Service
public class LoginServiceImpl implements LoginService {
	@Autowired public UserModelDAO userModelDao;
	
	@Override
	public int checkLogin(LoginData data, UserModelExample userEx, List<UserModel> listUser){
		int countRow= 0;
		userEx.setOrderByClause("USER_ID ASC");
		Criteria criteria= userEx.createCriteria();
		criteria.andUsernameEqualTo(data.getRt_admin_username());
		criteria.andPasswordEqualTo(data.getRt_admin_password());
		userEx.or(criteria);
		listUser= userModelDao.selectUserModelByExample(userEx);
		countRow= listUser.size();
		return countRow;
	}
}
